<?php
namespace App\Aspect;

use App\Exception\MaintenanceException;
use App\Http\Controller\ClientController;
use Swoft\Aop\Annotation\Mapping\Aspect;
use Swoft\Aop\Annotation\Mapping\Before;
use Swoft\Aop\Annotation\Mapping\PointBean;
use Swoft\Bean\BeanFactory;
use Swoft\Console\Router\Module;

/**
 * Class MaintenanceAspect
 * @package App\Aspect
 * @Aspect(order=1)
 * @PointBean(
 *     include={}
 * )
 */
class MaintenanceAspect
{

    /**
     * 在路由执行之前执行 判断是否是维护状态
     * @Before()
     */
    public function check(){

        // 判断 是否开启系统维护
        if (constant(Module::DEFINE_ENABLE_SYSTEM_MAINTAIN)) {
            // 开启了系统维护
            throw new MaintenanceException();
        }

    }

}
